<template>
    <div class="container" style="overflow-y:auto" id="aboutAgreement">
        <div class="wxParse" v-html="content"></div>
    </div>
</template>
<script>
    // import { getPosition } from '@/tools/index'
    import tools from "@/tools/index";
    import store from "@/tools/factory";
    import * as module from "@/tools/util";
    import * as Request from '@/api/liubike';
    let that = null;
    export default {
        data() {
            return {
                content: ''
            }
        },
        methods: {
            getPosition33() {
                return new Promise((resolve, reject) => {
                    if (navigator.geolocation) {
                        navigator.geolocation.getCurrentPosition(function (position) {
                            let latitude = position.coords.latitude
                            let longitude = position.coords.longitude
                            let data = {
                                latitude: latitude,
                                longitude: longitude
                            }
                            resolve(data)
                        }, function () {
                            reject(arguments)
                        })
                    } else {
                        reject('你的浏览器不支持当前地理位置信息获取')
                    }
                })
            },
            getLocation() {
                // 获取当前经纬度坐标
                tools.getPosition().then(result => {
                    // 返回结果示例：
                    // {latitude: 30.318030999999998, longitude: 120.05561639999999}
                    // 一般小数点后只取六位，所以用以下代码搞定
                    let queryData = {
                        lat: String(result.lat).match(/\d+\.\d{0,6}/)[0],
                        lng: String(result.lng).match(/\d+\.\d{0,6}/)[0],
                    }
                    console.log(queryData, 78)
                    store.set('locationInfo', JSON.stringify(queryData))
                    // 以下放置获取坐标后你要执行的代码:
                    // ...
                }).catch(err => {
                    console.log(err)
                })
               /* this.getPosition33().then(result => {
                    // 返回结果示例：
                    // {latitude: 30.318030999999998, longitude: 120.05561639999999}
                    // 一般小数点后只取六位，所以用以下代码搞定
                    console.log(result, 'resutl')
                    let queryData = {
                        latitude: String(result.latitude).match(/\d+\.\d{0,6}/)[0],
                        longitude: String(result.longitude).match(/\d+\.\d{0,6}/)[0],
                        channelType: '00'
                    }
                    console.log(queryData, 78)
                    // 以下放置获取坐标后你要执行的代码:
                    // ...
                }).catch(err => {
                    console.log(err)
                })*/
            },
            agreement(id) { // 获取用户协议
                Request.fetchAgreement({
                    id: id
                }).then(res => {
                    // console.log(res, 'res')
                    const data = module.isArray(res) ? res[0] : res;
                    if (data) {
                        let article = data.contents;
                        this.setData({
                            content: article
                        });
                    }
                });
            },
            setData(data) {
                if (Object.prototype.toString.call(data) === '[object Object]') {
                    for(let key in data) {
                        this[key] = data[key]
                    }
                }
            }
        },
        mounted() {
            this.getLocation()
            this.agreement(this.$route.query.id);
        }
    }
</script>
<style lang="stylus">
    #aboutAgreement {
        .MsoNormal {
            margin-bottom: 0.4rem !important;
        }
    }

</style>
<style scoped>
    .wxParse {
        padding: 0.2rem 0.5rem;
        font-size: 0.28rem;
        color: #666;
        line-height: 180%;
        -webkit-overflow-scrolling: touch;
        text-align: left;
    }

</style>
